#include <dspSimulator/command/next.h>
#include <dspSimulator/dspSimulator/dspSimulator.h>

void NextCommand::execute(std::string command) {
    auto dspSimulator = dynamic_cast<DSPSimulator *>(m_simulator);
    if (dspSimulator == nullptr) {
        fatalMacro("该模拟器对象不为dsp模拟器对象!");
    }
    dspSimulator->execute(m_executePacket);
    m_executePacket.clear();
}

std::shared_ptr<NextCommand>
NextCommand::get(Simulator *dspSimulator, std::vector<std::shared_ptr<Instruction>> &executePacket) {
    static std::shared_ptr<NextCommand> nextCommand;
    if (nextCommand == nullptr) {
        nextCommand = std::make_shared<NextCommand>(dspSimulator, executePacket);
    }
    return nextCommand;
}
